package m202406.d05;

import java.util.Map;
import java.util.Scanner;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/6/5 20:54
 */
public class OD153 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int lastAZ = -1;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c > '9' || c < '0') {
                lastAZ = i;
                break;
            }
        }
        //全是数字
        if (lastAZ == -1) {
            System.out.println(-1);
            return;
        }

        int start = 0;
        int end = lastAZ + 1;
        int max = lastAZ - start;

        while (end < s.length()) {
            char ec = s.charAt(end);
            if (ec > '9' || ec < '0') {
                max = Math.max(max, end - start);
                start = lastAZ + 1;
                lastAZ = end;
            }
            end++;
        }
        max = Math.max(max, end - start);
        System.out.println(max > 1 ? max : -1);
    }
}
